package com.ruoyi.classscoreonmonth.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.count.domain.Studentstandardscores;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.classscoreonmonth.domain.Classscoreonmonth;
import com.ruoyi.classscoreonmonth.service.IClassscoreonmonthService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 班级成绩生成Controller
 * 
 * @author yxy
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/classscoreonmonth/classscoreonmonth")
public class ClassscoreonmonthController extends BaseController
{
    @Autowired
    private IClassscoreonmonthService classscoreonmonthService;

    /**
     * 查询班级成绩生成列表
     */
    @PreAuthorize("@ss.hasPermi('classscoreonmonth:classscoreonmonth:list')")
    @GetMapping("/list")
    public TableDataInfo list(Classscoreonmonth classscoreonmonth)
    {
        startPage();
        List<Classscoreonmonth> list = classscoreonmonthService.selectClassscoreonmonthList(classscoreonmonth);
        return getDataTable(list);
    }

    /**
     * 导出班级成绩生成列表
     */
    @PreAuthorize("@ss.hasPermi('classscoreonmonth:classscoreonmonth:export')")
    @Log(title = "班级成绩生成", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Classscoreonmonth classscoreonmonth)
    {
        List<Classscoreonmonth> list = classscoreonmonthService.selectClassscoreonmonthList(classscoreonmonth);
        ExcelUtil<Classscoreonmonth> util = new ExcelUtil<Classscoreonmonth>(Classscoreonmonth.class);
        util.exportExcel(response, list, "班级成绩生成数据");
    }

    /**
     * 获取班级成绩生成详细信息
     */
    @PreAuthorize("@ss.hasPermi('classscoreonmonth:classscoreonmonth:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(classscoreonmonthService.selectClassscoreonmonthById(id));
    }

    /**
     * 新增班级成绩生成
     */
    @PreAuthorize("@ss.hasPermi('classscoreonmonth:classscoreonmonth:add')")
    @Log(title = "班级成绩生成", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Classscoreonmonth classscoreonmonth)
    {
        return toAjax(classscoreonmonthService.insertClassscoreonmonth(classscoreonmonth));
    }

    /**
     * 修改班级成绩生成
     */
    @PreAuthorize("@ss.hasPermi('classscoreonmonth:classscoreonmonth:edit')")
    @Log(title = "班级成绩生成", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Classscoreonmonth classscoreonmonth)
    {
        return toAjax(classscoreonmonthService.updateClassscoreonmonth(classscoreonmonth));
    }

    /**
     * 删除班级成绩生成
     */
    @PreAuthorize("@ss.hasPermi('classscoreonmonth:classscoreonmonth:remove')")
    @Log(title = "班级成绩生成", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(classscoreonmonthService.deleteClassscoreonmonthByIds(ids));
    }

    /**
     * 查询班级成绩生成列表按照老师的信息进行查询
     */
    @Anonymous
    @GetMapping(value = "/listByTeacher/{grade}/{school}/{classs}")
    public List<Classscoreonmonth> listByTeacher(@PathVariable("grade") String gradeId, @PathVariable("school") String schoolId ,@PathVariable("classs") String classs)
    {
        List<Classscoreonmonth> list = classscoreonmonthService.selectClassscoreonmonthListByTeacher(gradeId, schoolId, classs);
        return list;
    }

    /**
     * 根据教师的userName
     */
    @Anonymous
    @GetMapping(value = "/StudentlistByUserName/{userName}")
    public List<Studentstandardscores> listByTeacherName(@PathVariable("userName") String userName)
    {
        List<Studentstandardscores> list = classscoreonmonthService.selectClassscoreonmonthListByTeacherName(userName);
        return list;
    }
}
